package reco.db.validation

import reco.db.*

before "a not null constraint is created", {
    given "a field", {
        field = new DummyField()
        field.name = "field"
        field.domain = DummyDomain
        field.defaultValue = "default"
        field.definitionCompleted()
    }
    and "a not null constraint over the field", {
        constraint = new NotNullConstraint()
    }
}

scenario "null value is checked", {
    when "a null value is checked", {
        isValid = constraint.validate(null)
    }
    then "it should not be considered a valid value", {
        isValid.shouldBe false
    }
}

scenario "a not null value is checked", {
    when "a null value is checked", {
        isValid = constraint.validate(1)
    }
    then "it should be considered a valid value", {
        isValid.shouldBe true
    }
}
